# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: main.py
# Time: 17:25

import multiprocessing
import time

import pytest, os
from multiprocessing import Pool


device_infos = [{"platform_version": "10", "server_port": 4725, "device_port": "000001f4ad5c914e", "system_port": 8210},
                {"platform_version": "10", "server_port": 4723, "device_port": "7HX0219A09000974", "system_port": 8200}]



def run_parallel(device_info):
    pytest.main([f"--cmdopt={device_info}",
                 "--alluredir", "Reports"])
    os.system("allure generate Reports -o Reports/html --clean")


def print_device(device):
    print(device)

if __name__ == "__main__":
    print('主进程开始:%s' % multiprocessing.current_process().name)
    s_time = time.time()

    with Pool(2) as pool:
        pool.map(run_parallel, device_infos)
        pool.close()
        pool.join()

    print('主进程结束:%s' % multiprocessing.current_process().name)
    print('一共用时： ', time.time() - s_time)


